package cn.hchaojie.javase.week1;

import org.junit.Test;

public class Test5 {
	@Test
	public void test1() {
		int count = 10;
		
		while (count >= 1) {
			System.out.println(count);
			count--;
		}
	}
	
	@Test
	public void test2() {
		int count = 10;
		
		do {
			System.out.println(count);
			count--;
		} while (count >= 1);
	}
	
	// while里面是循环的运行条件，条件为真的时候会继续运行
	
	// 可以先写出循环终止条件，再求反
	@Test
	public void test3() {
		int dice1 = 0;
		int dice2 = 0;
		do {
			dice1 = (int) (Math.random() * 6 + 1);
			dice2 = (int) (Math.random() * 6 + 1);
			
			System.out.println(dice1 + "/" + dice2);
		//} while (!(dice1 == 6 && dice2 == 6));
		} while (dice1 != 6 || dice2 != 6);
		
		// 1, 4
		// 6, 1
		// 1, 6
		// 6, 6
		
		System.out.println("====================");

		do {
			dice1 = (int) (Math.random() * 6 + 1);
			dice2 = (int) (Math.random() * 6 + 1);
			
			System.out.println(dice1 + "/" + dice2);
			if (dice1 == 6 && dice2 == 6) {
				break;
			}
		} while (true);
		
		//
	}
}
